using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class KnapsackUI:BaseUI 
{
    public ItemsPanel itemsPanel;
    public Canvas[] myChildrenCanvas;
    private GraphicRaycaster[] myChildrenRaycaster;
    public playerCellUI weaponCell, armorCell, jewelryCell;
    protected new void Awake()
    {
        base.Awake();
        myChildrenRaycaster = new GraphicRaycaster[myChildrenCanvas.Length];
    }
    
    public override void ShowMe()
    {
        itemsPanel.SetAllItems();
        ShowEquip();
        base.ShowMe();
        myRaycaster.ignoreReversedGraphics = true;
        for (int i = 0; i < myChildrenCanvas.Length; i++)
        {
            if (myChildrenCanvas[i] != null)
            {
                myChildrenCanvas[i].enabled = true;
                myChildrenCanvas[i].gameObject.GetComponent<GraphicRaycaster>().ignoreReversedGraphics = true;
            }
        }
    }
    public override void CloseMe()
    {
        base.CloseMe();
        GameObject gm = GameObject.Find("UICanvas/top/detailPanel").gameObject;
        if (gm != null)
        {
            Canvas canvas = gm.GetComponent<Canvas>();
            canvas.enabled = false;
        }
    }
    public void ShowEquip()
    {
        weaponCell.SetItem(player.playerInfo.weapon);
        armorCell.SetItem(player.playerInfo.armor);
        jewelryCell.SetItem(player.playerInfo.jewelry);
        weaponCell.SetBackGroundColor();
        armorCell.SetBackGroundColor();
        jewelryCell.SetBackGroundColor();
    }
}
